package math;

import org.junit.Test;

/*
 *@description 阶乘后的零
 *@author hkfan
 *@version 1.0
 *@create 2025/6/23 16:50
 */
public class LeetCode_172 {
    @Test
    public void test(){
        System.out.println(trailingZeroes(5));
    }

    public int trailingZeroes(int n) {
        //1. 对每个数统计2、5、10的数目
        int num_2=0,num_5=0;
        for (int i = 2; i <= n ; i++) {
            num_2+=getCount(i,2);
            num_5+=getCount(i,5);
            //num_2+=getCount(i,10);
        }
        return Math.min(num_2,num_5);
    }

    public int getCount(int n,int num){
        int count = 0;
        while (n%num==0){
            count++;
            n/=num;
        }
        return count;
    }

}
